import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {ParkingArea} from '../../types/resp/ParkingArea';

@Component({
  selector: 'parking-area-view',
  imports: [
    SharedModule
  ],
  templateUrl: './parking-area-view.component.html',
  standalone: true
})
export class ParkingAreaViewComponent implements OnInit {
  parkingAreaForm!: FormGroup;
  isVisible: boolean = false
  title: string = '车位信息详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.parkingAreaForm = this.fb.group({
      areaNumber: [''],
      buildingName: [''],
      floorNumber: [''],
      residentRoomNumber: [''],
      licensePlate: [''],
      status: [undefined],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(parkingArea: ParkingArea) {
    this.isVisible = true
    this.parkingAreaForm.patchValue(parkingArea);
    this.parkingAreaForm.disable();
  }
}
